home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Id: init.c,v 0.91 1994/02/20 00:52:57 zhao Pre-Release $
- *
- *. This file is part of BIT shareware package. After the two weeks of
- * free evaluation period, you are encouraged (required) to register
- * your copy for a small registration fee, which is $35 for personal use
- * and $50 for commercial, government and institutional use.
- *
- * Copyright(c) 1993, 1994 by T.C. Zhao.
- * All rights reserved.
- *
- * Permission to use, copy, and distribute this software in its entirety
- * for non-commercial purposes is hereby granted, provided that the
- * above shareware and copyright notices and this permission notice
- * appear in all copies and their documentation.
- *
- * This software may be modified for your own use, but modified versions
- * may not be distributed without prior consent of the author.
- *
- * This software is provided "as is" without expressed or implied
- * warranty of any kind.
- *
- *.
- *
- * Initialization: process, graphics, forms.
- *
- */
- #if !defined(lint) && defined(F_ID)
- char *id_init = "$Id: init.c,v 0.91 1994/02/20 00:52:57 zhao Pre-Release $";
- #endif
-
- #include "bit.h"
- #include "extern.h"
- #include <stdlib.h>
- #include "dmalloc.h"
- #include <sys/types.h>
- #include <sys/signal.h>
- #include <signal.h>
- #include <setjmp.h>
-
- /************ Local functions ***********************************/
-
- static void non_graphics_init(void);
- static void check_graphics_cap(void);
- static void init_configsys(void);
-
- /****************************************************************
- * Global interface: do all the initialization, except for fonts
- * which are done in text.c
- *****************************************************************/
-
- void
- bit_init(void)
- {
- /* message generation threshold */
- set_msg_threshold(verbose);
-
- /* where error messages go */
- set_err_msg_fp(stderr);
-
- /* initialize signal handlers and other things */
- non_graphics_init();
-
- /*
- * initialize graphics default and forms library. If foreground is
- * requested, do it here as check_graphics_cap calls winopen (the first
- * one) to save current colormap
- */
-
- if (!run_in_background)
- foreground();
-
- check_graphics_cap();
-
- gui_init();
-
- /* show initial window */
- open_main_window(imgptr);
-
- if (!no_panel)
- show_info_window(-1, -1, -1, -1, 1);
-
- if (showedit && !no_panel)
- show_control_window(-1, -1, -1, -1, 0);
-
- init_configsys();
- }
-
- /*******************************************************************
- * following signal will be trapped and program will exit upon receiving
- * any of these. If SEGV or BUS is received, also send a messag to me.
- *********************************************************************/
-
- typedef struct
- {
- int sig;
- const char *text;
- }
- SIGTEXT;
-
- static SIGTEXT stext[] =
- {
- {SIGILL, "Illegal instruction"},
- {SIGBUS, "Bus error"},
- {SIGSEGV, "Segmentation violation"},
- {SIGUSR1, "USR1--Killed by child"}, /* what was used for */
- {SIGUSR2, "USR2--Q reset by child"} /* Not used */
- };
-
- static int total = sizeof(stext) / sizeof(SIGTEXT);
-
- #ifdef MAIL_AUTHOR
- static const char *myaddress = "zhao@bragg.phys.uwm.edu";
- #endif
-
- /*************************************************************
- * all signals ended up here
- **************************************************************/
- static void
- sig_handler(int sig)
- {
- SIGTEXT *st = stext + total;
- char buf[200];
-
- /*
- * Echo what kind of signal is received. Note that this might not work if
- * segv or busE
- */
-
- while (--st >= stext)
- {
- if (st->sig == sig)
- M_info("SigH", "Received SIG=%d %s", sig, st->text);
- }
-
- /* handle this signal */
- switch (sig)
- {
- case SIGUSR2:
- case SIGUSR1: /* child will send this one */
- break;
-
- case SIGSEGV: /* hell breaks loose */
- fputs("InternalError: Segmentation violation\n", stderr);
- #ifdef MAIL_AUTHOR
- sprintf(buf, "echo 'segv %s' | Mail -s 'segv' %s 1>%s 2>&1",
- rm_rcs_kw(sver), myaddress, "/dev/null");
- (void) system(buf);
- #endif
- break;
-
- case SIGBUS:
- fputs("InternalError: Bus error\n", stderr);
- #ifdef MAIL_AUTHOR
- sprintf(buf, "echo 'BusE %s' | Mail -s 'BusE' %s 1>%s 2>&1",
- rm_rcs_kw(sver), myaddress, "/dev/null");
- (void) system(buf);
- #endif
- break;
-
- default:
- fprintf(stderr, "Unknowm signal %d\n", sig);
- break;
- }
-
- clean_up();
- }
-
- /*******************************************************************
- * Quit immediately if basic assumption of the system is wrong.
- * currently not likely (possible ?)
- ******************************************************************/
-
- static void
- check_basic_assumptions(void)
- {
- /* getmat and submat (maybe others assume the following) */
- if ((sizeof(char *) != sizeof(short *)) ||
- (sizeof(char *) != sizeof(long *)) ||
- (sizeof(char *) != sizeof(char **)))
- {
- fputs("Sorry. Wrong assumptions", stderr);
- exit(0);
- }
- }
-
- /*******************************************************************
- * initialize all stuff not related to graphics
- *******************************************************************/
-
- static void
- non_graphics_init(void)
- {
- SIGTEXT *st = stext + total;
-
- check_basic_assumptions();
-
- /* install signal handlers */
-
- while (--st >= stext)
- signal(st->sig, sig_handler);
-
- #ifdef CORE
- /* dump core if requested */
- signal(SIGSEGV, SIG_DFL);
- signal(SIGBUS, SIG_DFL);
- #endif
-
- /* get_mem_imgptr quits if unable to get it */
-
- imgptr = get_mem_imgptr();
- imgptr->cmap = get_mem_cmap();
-
- #ifdef PROTECT
- protect();
- #endif
-
- }
-
- /*****************************************************************
- * Check and maybe choose optimal graphics configurations
- *****************************************************************/
-
- static void
- check_graphics_cap(void)
- {
- int n;
-
- if (getgdesc(GD_BITS_NORM_SNG_RED) == 0)
- {
- fputs("RGBmode is not available\n", stderr);
- exit(0);
- }
-
-
- /*
- * turn double buffer on only if capable. Would rather look ugly and
- * flickering than wrong
- */
-
- double_buf = double_buffer_capable();
-
-
- #ifndef NO_NP_DBL
- simu_dbl_buffer = 1;
- #endif
-
- #ifndef NO_OP_DBL
- /*
- * due to some reason, simulation does not work well in pupdraw. need to
- * check some more. turn it off
- */
- simu_op_dblbuf = getgdesc(GD_BITS_OVER_SNG_CMODE) > 1;
- #endif
-
- if ((n = getgdesc(GD_BITS_NORM_SNG_CMODE)) < CMAPBITS && n >= 9)
- {
- fprintf(stderr, "Please change CMAPBITS in utype.h from %d to %d\n",
- CMAPBITS, n);
- }
-
- n = getgdesc(GD_BITS_NORM_SNG_CMODE);
-
- errno = 0;
-
- M_info("Init", "SingleBuffer CMAPbits: %d", n);
-
- if (n < 9 || CMAPBITS < 9)
- {
- if (verbose > 1)
- fputs("CMAPBITS < 9. Performance untested\n", stderr);
-
- if (CMAPBITS < 8)
- {
- fputs("BIT can't work with less than 8 bits\n", stderr);
- exit(1);
- }
- }
-
- M_info("Init", "%s in double buffer mode", double_buf ? "" : "Not");
-
- /* check anti-aliasing capabilities */
-
- smooth_lines = sml_capable();
- M_info("Init", "smooth line is %ssupported", smooth_lines ? "" : "not ");
-
- /* save current system map for later restore */
- get_sysmap();
- }
-
-
- /*************************************************************
- * read n positive integers. If an error occurs, skip to the
- * the end of the line.
- **************************************************************/
-
- static int
- readnint(FILE * fp, int n, int x[])
- {
- int i, err;
- for (i = err = 0; !err && i < n; i++)
- err = ((x[i] = readpint(fp)) < 0);
-
- /* skip until either the end of line or EOF */
- if (err)
- while ((i = getc(fp)) != EOF && i != '\n')
- ;
- return err;
- }
-
-
- /********************************************************************
- * bring up the main viewing window and possibly set all inital
- * panel locations
- ********************************************************************/
-
- static const char *winposfile = "WinPosition";
-
- /*********************************************************************
- * Read initial window placement from startup file if requested
- ********************************************************************/
- static void
- read_win_pos(void)
- {
- int xy[4];
- int prefp = !auto_position && !full_win;
- FILE *fp = 0;
-
- if ((fp = get_BITfile_fp(winposfile, "r")))
- {
- int readok = readnint(fp, 4, xy) == 0;
-
- if (verbose > 1)
- fprintf(stderr, "%s %s read\n", winposfile,
- readok ? "OK" : "Bad");
-
- if (readok && prefp)
- {
- win_xo = xy[0];
- win_yo = xy[1];
- win_w = xy[2];
- win_h = xy[3];
- }
- }
-
- /* get default panel positions */
- xy[0] = xy[2] = -1;
- xy[1] = 5;
- xy[3] = 350;
-
- if (fp)
- {
- readnint(fp, 4, xy);
- fclose(fp);
- }
-
- /* the info panel */
- set_info_window_position(xy[0], xy[1]);
-
- /* the control panel */
- set_control_window_position(xy[2], xy[3]);
- }
-
- void
- open_main_window(IPTR im)
- {
- int dx = 285;
- int bk = 10, g_xmax, g_ymax;
- char *ttt = rm_rcs_kw(sver);
- char tbuf[512];
-
- /*
- * if fit_image_size == 2, always force the window size to be that of the
- * image. Also need to demand image ready status to avoid flashing
- */
-
- if (win_id > 0)
- {
- /* demand ready status */
- if (fit_image_size == 2 && im && im->ok)
- {
- long x, y;
- set_current_window(win_id);
- getorigin(&x, &y);
- win_w = im->w;
- win_h = im->h;
- winposition(x, x + win_w - 1, y, y + win_h - 1);
- }
- return;
- }
-
- screen_xp = g_xmax = getgdesc(GD_XPMAX);
- screen_yp = g_ymax = getgdesc(GD_YPMAX);
-
- show_clock_mailbox(g_xmax - 200, g_ymax - 120, 0, 0);
-
- /* default window position and size */
-
- win_xo = win_yo = bk;
-
- if (fit_image_size)
- {
- if (!im || im->type == T_FLEX || im->w <= 1)
- {
- read_win_pos(); /* needed to set panel pos */
- return;
- }
-
- win_w = im->w;
- win_h = im->h;
- }
- else
- {
- win_w = g_xmax - ((full_win) ? 2 * bk : dx);
- win_h = g_ymax - 40;
- }
-
- /* read_win_pos will do proper thing if !fit_image */
- if (!fit_image_size)
- read_win_pos();
-
- /* final constraints */
- if (win_w > g_xmax)
- win_w = g_xmax;
- if (win_h > g_ymax)
- win_h = g_ymax;
-
-
- #ifndef REGISTERED
- {
- strcat(strcpy(tbuf, ttt), "-- ");
- ttt = strcat(tbuf, unreg);
- }
- #endif
-
- prefposition(win_xo, win_w + win_xo - 1, win_yo, win_h + win_yo - 1);
-
- if ((win_id = winopen(ttt)) < 0)
- {
- fputs("Error opening window\n", stderr);
- clean_up();
- }
- wintitle(ttt);
-
- M_info("Init", "ScreenSize %dX%d", screen_xp, screen_yp);
-
- /* make the window size changeable */
- minsize(60, 60);
- iconsize(110, 89);
- winconstraints();
-
- if (double_buf)
- doublebuffer();
-
- /*
- * initialize cursor, overplane. Must come after the graphics system is
- * initialized, say by a winopen
- */
-
- glu_init();
-
- /*
- * must call gconfig here regardless if double buffer because glu_init
- * might've called other configuration routine
- */
-
- gconfig();
-
- /* clear screen */
- clear_over_pup();
- set_bk_color(background_color);
- clear_screen(win_id, 1);
-
-
- /* queue all devices */
- fl_qdevice(RIGHTMOUSE);
- fl_qdevice(MIDDLEMOUSE);
- fl_qdevice(LEFTMOUSE);
-
- fl_qdevice(CKEY); /* current image */
- fl_qdevice(SPACEKEY); /* next image */
- fl_qdevice(PKEY); /* previous image */
- fl_qdevice(MKEY); /* show menu */
- fl_qdevice(SKEY); /* slides mode off */
-
- fl_qdevice(F1KEY); /* used internally */
-
- fl_qdevice(KEYBD);
- fl_qdevice(PAUSEKEY);
- fl_qdevice(LEFTCTRLKEY);
- fl_qdevice(RIGHTCTRLKEY);
- fl_qdevice(LEFTALTKEY);
- fl_qdevice(WINTHAW);
- fl_qdevice(WINFREEZE);
- fl_qdevice(WINQUIT);
- fl_qdevice(WINSHUT);
- fl_qdevice(LEFTARROWKEY);
- fl_qdevice(UPARROWKEY);
- fl_qdevice(DOWNARROWKEY);
- fl_qdevice(RIGHTARROWKEY);
-
- }
-
-
- /**************************************************************
- * save current window locations
- **************************************************************/
-
- /*ARGSUSED */
- int
- save_win_position(int n)
- {
- long owin = winget();
- FILE *fp;
-
- if (!(fp = get_BITfile_fp(winposfile, "w")))
- {
- Bark("SaveWinPos", "Bad open");
- return -1;
- }
-
- set_current_window(win_id);
- getorigin(&win_xo, &win_yo);
- getsize(&win_w, &win_h);
- fprintf(fp, "%ld %ld %ld %ld # MainWindow Location & Size\n",
- win_xo, win_yo, win_w, win_h);
-
- write_info_window_position(fp);
- write_control_window_position(fp);
- fclose(fp);
-
- set_current_window(owin);
-
- return 0;
- }
-
- /************************************************************
- * get screen information. Maybe used by PostScript routine
- *************************************************************/
- int
- get_scr_dpi(void)
- {
- int xm = getgdesc(GD_XMMAX);
- int ym = getgdesc(GD_YMMAX);
- int xdpi = ((float) getgdesc(GD_XPMAX) / (xm / 25.4) + 0.5);
- int ydpi = ((float) getgdesc(GD_YPMAX) / (ym / 25.4) + 0.5);
-
- if (Abs(xdpi - ydpi) > 5)
- { /* non-square pixel */
- M_info("ScrDPI", "Non-Square Pixel: Xdpi=%d Ydpi=%d", xdpi, ydpi);
- }
-
- return (xdpi + ydpi) / 2;
- }
-
-
- /***************************************************************
- * show clock and mailbox
- ***************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "unistd.h"
- #include <sys/types.h>
- #include <signal.h>
-
- /******************************************************************
- * in bit, only one copy of clock_mail is allowed to run.
- * This is the lock file, which also contains the PID of clock_mail,
- * in case clockmail wants to check if the said process is still
- * alive.
- ******************************************************************/
- #ifndef LOCK_FILE
- #define LOCK_FILE ".iclock.lc"
- #endif
-
- /* name of the program to run */
- #ifndef CLOCK_MAIL
- #define CLOCK_MAIL "clockmail"
- #endif
-
- static char local[150];
- static int gid, pid, cid;
-
- void
- show_clock_mailbox(int x, int y, int w, int h)
- {
- static int lx = -1, ly, lw, lh;
-
- pid = getpid();
- gid = setpgrp();
-
- if (no_panel || no_clockmail)
- return;
-
- /*
- * due to further forking in clock_mailbox, the fork does not give the
- * correct process id. We can get it from the lockfile of the
- * clock_mailbox
- */
-
- if (fork() == 0)
- {
- if (x > 0 && y > 0)
- {
- lx = x;
- ly = y;
- lw = w;
- lh = h;
- sprintf(local, "%s -fb -p %d %d %d %d %d", CLOCK_MAIL, pid,
- x, y, w, h);
- }
- else if (lx >= 0)
- {
- sprintf(local, "%s -fb -p %d %d %d %d %d", CLOCK_MAIL, pid,
- lx, ly, lw, lh);
- }
- else
- {
- sprintf(local, "%s -fb -p %d ", CLOCK_MAIL, pid);
- }
- (void) execlp("/bin/sh", CLOCK_MAIL, "-c", local, (char *) 0);
- perror("execl");
- }
-
- if (x > 0 && y > 0)
- {
- lx = x;
- ly = y;
- lw = w;
- lh = h;
- }
-
- }
-
- /* kill clock_mail when bit quits */
- void
- process_clean_up(void)
- {
- if (run_in_background)
- {
- if (kill(0, SIGKILL))
- perror("killgid0");
- }
- }
-
- static char lockfile[1024];
-
- void
- remove_clock_mailbox(void)
- {
- char line[150];
-
- cid = -1;
-
- /* generate the lock filename */
- if (lockfile[0] == '\0')
- {
- strncpy(lockfile, getenv("HOME"), sizeof(lockfile));
- lockfile[sizeof(lockfile) - 1] = '\0';
- strncat(lockfile, "/", sizeof(lockfile) - 1);
- strncat(lockfile, LOCK_FILE, sizeof(lockfile) - 1);
- }
-
- /* check if the process is still alive */
- if (access(lockfile, R_OK) == 0)
- {
- FILE *fp = fopen(lockfile, "r");
- fgets(line, sizeof(line), fp);
- fclose(fp);
- cid = atoi(line);
- }
-
- /* kill it. clockmail will cleanup the lockfile */
- if (cid > 0)
- kill(cid, SIGUSR1);
- }
-
- /*******************************************************************
- * Configure
- *******************************************************************/
-
- static int cm = -1;
- static int cfg_zoomx, cfg_zoomy;
-
- /* built-in Pause in SlideShow mode, in milli-second */
- static int fpause[] =
- {
- 0, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 60000, -1
- };
-
- void
- slideshow_off(void)
- {
- slide_pause_index = 0;
- slideshow = 0;
- }
-
- /**********************************************************************
- * given slide show pausing intervals, generate the string version of it.
- * the function is complicated by the fact that command line might set the
- * interval to something not in the table, we use the last slot for it
- **********************************************************************/
-
- static const char *
- gpause_string(void)
- {
- static char localstr[120];
- char pp[20];
- int i, delta = 100000;
- int npause = sizeof(fpause) / sizeof(fpause[0]);
-
- localstr[0] = '\0';
-
- strcpy(localstr, "Off");
- for (i = 0; i < npause; i++)
- {
- if (fpause[i] > 0)
- {
- sprintf(pp, "|%.2fs", (float) fpause[i] * 0.001);
- strcat(localstr, pp);
- if (delta < Abs(slideshow - fpause[i]))
- {
- delta = Abs(slideshow - fpause[i]);
- slide_pause_index = i;
- }
- }
- }
-
- if (delta && slideshow)
- { /* command line has set it */
- fpause[npause - 1] = slideshow;
- sprintf(pp, (slideshow > 99) ? "|%.1fs" : "|%.2fs",
- (float) fpause[npause - 1] * 0.001);
- strcat(localstr, pp);
- slide_pause_index = npause - 1;
- }
-
- return localstr;
- }
-
- /*********************************************************************
- * built-in percentages for progress report
- *********************************************************************/
-
- static int report_percent[] =
- {
- 0, 2, 5, 10, 20
- };
-
- static const char *
- greport_string(void)
- {
- return "Off|2%|5%|10%|20%";
- }
-
- /****************************************************************
- * the configuration structure. If opt is null, function gopt
- * is called to get the option string. This way we localize
- * the option change to the defination file
- *****************************************************************/
-
- typedef struct
- {
- const char *vstr; /* variable name */
- const char *exp1, *exp2; /* brief explanatin */
- int *var, val; /* the variable. Val unused */
- const char *opt; /* string version of values */
- const char *(*gopt) (void); /* funciton that generates strings */
- }
- Opt_t;
-
- #if defined(MTRACE)
- #define MMSG "Error|Warning|Info|Debug|Trace"
- #else
- #if defined(MDEBUG)
- #define MMSG "Error|Warning|Info|Debug"
- #else
- #define MMSG "Error|Warning|Info"
- #endif
- #endif
-
- static int qdither_method;
- static Opt_t opt[] =
- {
- {"DisplayStyle",
- "Many styles to display an image. Block is the most efficient",
- "While CYCLE will cycle thru all methods",
- &display_style, 0, 0, gds_string
- },
-
- #ifndef SGL_BUF
- {"DoubleBuffer",
- "Turn double buffer on and off",
- 0,
- &double_buf, 0, "Off|On", 0
- },
- #endif
-
- {"AlwaysRefreshScreen",
- "Controls if the screen should be refreshed",
- "Before each display",
- &always_clear, 0, "No|Yes", 0
- },
-
- {"SlideShow",
- "Interval between each frame, in seconds",
- "",
- &slide_pause_index, 0, 0, gpause_string
- },
-
- {"ProgressReport",
- "controls if to report progress and how frequent (in %).",
- "This does not affect reporting by cursor",
- &report_level, 0, 0, greport_string
- },
-
- {"PSResolution",
- "resolution to use when converting PS file to raster",
- "large value will result in large image files",
- &ps_res_index, 0, 0, gps_res_string,
- },
-
- {"XMagnification",
- "Magnification power in X-direction",
- "Applicable in BLOCK display mode only",
- &cfg_zoomx, 0, "Auto|1|2|3|4|5", 0
- },
-
- {"YMagnification",
- "Magnification power in Y-direction",
- "Applicable in BLOCK display mode only",
- &cfg_zoomy, 0, "Auto|1|2|3|4|5", 0
- },
-
- {"AutoPan",
- "",
- "",
- &always_pan, 0, "Never|SlidesOnly|Always", 0
- },
-
- {"PreserveWMcolors",
- "Controls if to preserve the colors window manager uses",
- "via colormap re-ordering.",
- &preserve_wm_colors, 0, "No|Yes", 0
- },
-
- {"AlwaysUseBorder",
- "This setting controls if all control panels should have a border",
- "",
- &always_border, 0, "No|Yes", 0
- },
-
- {"ShowCutBuffer",
- "Show current cut buffers while moving",
- "Could be slow on old machines",
- &show_cut_buffer, 0, "No|Yes", 0
- },
-
- /*
- * if simulate double buffering. Hardware doublebuffering, double_buf,
- * overwrites this setting
- */
-
- #ifndef NO_NP_DBL
- {"SimuDBLBuffer",
- "Turn simulation of double buffering on and off",
- 0,
- &simu_dbl_buffer, 0, "Off|On", 0
- },
- #endif
-
- #ifndef NO_OP_DBL
- {"SimuOPDblBuf",
- "Turn on and off the simulation of double buffering",
- "in overlay/pupdraw",
- &simu_op_dblbuf, 0, "Off|On", 0
- },
- #endif
-
- {"AutoCropFill",
- "Controls if to fill the portion outside the region of interest",
- "",
- &crop_fill, 0, "No|Ask|Yes", 0
- },
-
-
- {"AlwaysReadScrn",
- "Controls the mode of operation for crop",
- "If no, internal memory copy is used",
- &always_readscrn, 0, "No|Yes", 0
- },
-
- {"SmoothLines",
- "To turn on and off anti-aliasing in line drawing",
- "No effect if hardware is not capable",
- &smooth_lines, 0, "Off|On", 0
- },
-
- {"HalftoneMethod",
- "", "",
- &halftone_method, 0, 0, bw_dither_string
- },
-
- {"QuantizationMethod",
- "", "",
- &quant_method, 0, 0, quant_opt_string
- },
-
- {"QuantDither",
- "", "",
- &qdither_method, 0, 0, qdither_opt_string
- },
-
- {"KeepTextAndSgf",
- "Controls if text and simple geometric figures should be kept",
- "across images",
- &keepmisc, 0, "No|Yes", 0
- },
-
-
- {"DelFromDiskConfirm",
- "Controls if confirmation should be asked",
- "when deleting files from disk",
- &always_delete, 0, "Yes|No", 0
- },
-
-
- {"AutoChangeExt",
- "Change file extension according to its format when writing",
- 0,
- &auto_ext, 0, "No|Yes", 0
- },
-
- {"AutoRemoveFromList",
- "If set, files that are in error will be removed from",
- "the active list (no disk activities)",
- &auto_remove, 0, "No|Ask|Yes", 0
- },
-
- {"ReportMouseLocation",
- "Controls report mouse location reporting and ",
- "location origin",
- &report_mouse, 0, "No|Window|Image", 0
- },
-
- {"AutoRemoveIcon",
- "controls if to delete image browser icon when orginial",
- "image no long exists",
- &auto_remove_thumbnail, 0, "No|Yes", 0
- },
-
- {"MessageVerbosity",
- "controls amount of the messages to be generated",
- "Lots of messages if trace",
- &verbose, 0, MMSG, 0
- },
-
- {"ShowEditAuto",
- "Whether bring up the edit panel automatically",
- "upon start-up",
- &showedit, 0, "No|Yes", 0
- },
-
- {"ConfirmOnLoad",
- "Whether to nag about image changes",
- "when loading new files",
- &abort_change_ask, 0, "No|Yes", 0
- }
- };
-
- static void
- init_configsys(void)
- {
- int err, nopt = sizeof(opt) / sizeof(opt[0]);
- Opt_t *p = opt, *ps;
-
- /* set error output routine default */
- set_msg_threshold(verbose);
- set_err_msg_fp(stderr);
- set_read_silent(verbose == 0); /* in ulib */
- set_err_msg_func(TC_continue);
- set_err_msg_brief(verbose <= 1);
-
- /*
- * Note that every option should not have space in between as the option
- * loading module can't read it. Space in front or end is ok.
- */
- if (cm < 0)
- {
- if ((cm = def_option("Setup", 0, "option.hlp")) < 0)
- {
- Bark("SetUp", "Unable to define menu");
- return;
- }
-
- set_option_act(cm, "SaveWinPos", save_win_position);
-
- for (err = 0, ps = p + nopt; !err && p < ps && p->vstr; p++)
- {
- if (!p->opt)
- p->opt = p->gopt ? p->gopt() : "Unkwnon";
- err = addto_option(cm, p->vstr, p->exp1, p->exp2,
- p->var, p->opt, 0) < 0;
- }
-
- if (err)
- {
- M_warn("InitConfig", "Something is wrong");
- return;
- }
- }
- percent_report = report_percent[report_level];
- set_quant_parameters(-1, qdither_method, quant_method - 1);
- }
-
- /*******************************************************************
- * Override options either set via Startup file or command line.
- ******************************************************************/
- void
- hardware_constraints(int override)
- {
- if (!double_buf && double_buffer_capable())
- M_info("Config", "Please turn double buffer on");
-
- /* double buffer might've been turned on */
- if (double_buf && !double_buffer_capable())
- {
-
-
- errno = 0; /* shut up inaccurate reports */
-
- M_err("Config", "Not enuf bitplanes for double buffering");
-
- if (override)
- double_buf = 0;
- else
- M_err("Config", "Please turn dobule buffer off");
- }
- }
-
- void
- config_sys(void)
- {
- int lastdblbuf = double_buf;
-
- if (cm < 0)
- init_configsys();
-
- cfg_zoomx = (g_zoomx + 0.1);
- cfg_zoomy = (g_zoomy + 0.1);
-
-
- do_option(cm);
-
- /*** Some of the setting require immediate action. Do it now **/
-
- g_zoomx = cfg_zoomx;
- g_zoomy = cfg_zoomy;
-
-
- /* error message generation */
- set_msg_threshold(verbose);
- set_err_msg_brief(verbose <= 1);
-
- slideshow = fpause[slide_pause_index];
- percent_report = report_percent[report_level];
- set_quant_parameters(-1, qdither_method, quant_method - 1);
-
- /* final check to make sure everything is OK */
-
- hardware_constraints(1);
-
- /* if different request, re-configure and display */
- if ((lastdblbuf - double_buf))
- repaint(imgptr, win_id);
-
- return;
- }
-